<template>
  <div class="member-bg">
    <div class="member-card">
      <div class="member-search-row" >
        <input v-model="search" class="member-search" @input="doSearchDebounced" :placeholder="$t('views.member.searchPlaceholder')" />
        <button class="member-search-btn" @click="addUser">
          <i class="iconfont icon-tianjia" style="font-size: 25px;"></i>
        </button>
    
        <div class="member-search-btn" style="width: 100px;border-radius: 30px;" >
          <i >{{ pageNum }}</i>
          <i >/</i>
          <i >{{ totalPage }}</i>
        </div>
      </div>

      <div class="member-list" @scroll.passive="onScroll">
        <div class="member-item" v-for="(user, idx) in users" :key="user.id" @click="selectUser(user)" :class="{ selected: currentUser === user.id }">
          <i class="iconfont icon-xiugai" style="font-size: 25px;
          font-weight: bold;

          position: absolute;top: 2px;right: 10px;" @click.stop="editUser(user)"></i>
          <div class="member-avatar-box">
            <div class="member-avatar">
              <img v-if="user.sex==1" src="../../assets/image/heardimg1.png" style="border-radius: 50%;width: 100%;height: 100%;object-fit: cover;" alt="头像" />
              <img v-else src="../../assets/image/heardimg.png" style="border-radius: 50%;width: 100%;height: 100%;object-fit: cover;" alt="默认头像" />
              </div>
            
          </div>
          <div class="member-name-row">
            <span class="member-name" style="margin-bottom: 10px;">{{ user.name || $t('views.member.defaultUsername') }}</span>
            <i class="iconfont icon-nv" style="font-size: 20px;"  v-if="user.sex == 1" ></i>
            <i class="iconfont icon-nan" style="font-size: 20px;"  v-else ></i>
          </div>
          <div class="member-info-row">
            {{ $t('views.member.age') }}{{ user.age || '--' }}
            <span class="member-id">| {{ user.anamnesisid?.slice(0,4) }}...{{ user.anamnesisid?.slice(-4) }}</span>
          </div>
          <div class="member-btn-row">
            <button class="member-btn" @click.stop="goReport(user)">{{ $t('views.member.report') }}</button>
            <button class="member-btn" @click.stop="goPlan(user)">{{ $t('views.member.plan') }}</button>
          </div>
          <button class="member-btn2" @click.stop="selectUser(user)">{{ $t('views.member.selectUser') }}</button>

        </div>
        <!-- <div v-if="loading" style="width:100%;text-align:center;padding:16px 0;color:#888;">加载中...</div>
        <div v-if="!hasMore && users.length>0" style="width:100%;text-align:center;padding:16px 0;color:#888;">没有更多了</div> -->
      </div>
      <div class="page">
        <button class="page-btn u-f-ajc" @click="goPrevPage" :disabled="pageNum <= 1">
          <i class="iconfont icon-zuobian"></i>
        </button>
        
        <template v-for="page in getPageNumbers()" :key="page">
          <button 
            v-if="page !== '...'"
            class="page-number u-f-ajc" 
            :class="{ active: page === pageNum }"
            @click="goToPage(page)"
          >
            {{ page }}
          </button>
          <span v-else class="page-ellipsis">...</span>
        </template>
        
        <button class="page-btn u-f-ajc" @click="goNextPage" :disabled="pageNum >= totalPage">
          <i class="iconfont icon-youbian"></i>
        </button>
      </div>
    </div>
    <Dialog ref="dialogRef" >
      <div class="user-dialog-flex">
        <div class="user-dialog-form">
          <div class="form-row">
            <div class="form-label required">{{ $t('views.member.nameRequired') }}</div>
            <input v-model="form.name" class="form-input underline" :placeholder="$t('views.member.enterNamePlaceholder')" />
          </div>
          <div class="form-row">
            <div class="form-label">{{ $t('views.member.gender') }}</div>
            <div class="sex-btn-group">
              <button type="button" class="sex-btn u-f-ajc" :class="{active: form.sex==0}" @click="form.sex=0">
                <i class="iconfont icon-nan"></i>
              </button>
              <button type="button" class="sex-btn u-f-ajc" :class="{active: form.sex==1}" @click="form.sex=1">
                <i class="iconfont icon-nv"></i>
              </button>
            </div>
          </div>
       
        
          <div class="form-row">
            <div class="form-label">{{ $t('views.member.birthday') }}</div>
            <el-date-picker
              v-model="form.birthday"
              type="date"
              :placeholder="$t('views.member.selectBirthdayPlaceholder')"
              format="YYYY-MM-DD"
              value-format="YYYY-MM-DD"
              class="form-date-picker"
              :picker-options="{
                firstDayOfWeek: 1
              }"
            />
          </div>
          <div class="form-row">
            <div class="form-label">{{ $t('views.member.idNumber') }}</div>
            <input v-model="form.anamnesisid" class="form-input underline" :placeholder="$t('views.member.caseSensitivePlaceholder')" />
          </div>
          <div class="form-row">
            <div class="form-label">{{ $t('views.member.remark') }}</div>
            <textarea v-model="form.remark" class="form-input underline" :placeholder="$t('views.member.enterRemarkPlaceholder')" />
          </div>
        </div>
        <div class="user-dialog-avatar">
          <label class="avatar-img avatar-upload-label" for="avatar-upload-input">
            <img v-if="form.sex==1" src="../../assets/image/heardimg1.png" alt="头像" />
            <img v-else src="../../assets/image/heardimg.png" alt="默认头像" />
            <input id="avatar-upload-input" type="file" accept="image/*" class="avatar-upload" @change="onAvatarChange" style="display:none;" />
          </label>
          <!-- <div class="avatar-upload-desc">设置头像</div> -->
        </div>
      </div>
      <div class="dialog-btn" style="margin-top: 40px;">
        <button class="dialog-confirm" @click="onFormConfirm">{{ $t('common.confirm') }}</button>
        <button class="dialog-cancel" @click="dialogRef.close()">{{ $t('common.cancel') }}</button>
      </div>
    </Dialog>
    <Dialog ref="switchDialogRef">
      <div class="switch-dialog-content">
        <div class="switch-dialog-title">{{ $t('views.member.confirmSwitchUser', { username: switchUserName }) }}</div>
        <div class="dialog-btn" style="margin-top: 30px;">
          <button class="dialog-confirm" @click="onSwitchConfirm">{{ $t('common.confirm') }}</button>
          <button class="dialog-cancel" @click="switchDialogRef.close()">{{ $t('common.cancel') }}</button>
        </div>
      </div>
    </Dialog>
    <Dialog ref="deleteDialogRef">
      <div class="switch-dialog-content">
        <div class="switch-dialog-title">{{ $t('views.member.confirmDeleteUser', { username: deleteUserName }) }}</div>
        <div class="dialog-btn" style="margin-top: 30px;">
          <button class="dialog-confirm" @click="onDeleteConfirm">{{ $t('common.confirm') }}</button>
          <button class="dialog-cancel" @click="deleteDialogRef.close()">{{ $t('common.cancel') }}</button>
        </div>
      </div>
    </Dialog>
  </div>
</template>

<script setup lang="ts">
import { ElLoading } from 'element-plus'
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
import { useRouter } from 'vue-router'
import Dialog from '../../components/Dialog.vue'

// 使用备用翻译系统
let t: any = (key: any) => key
let setLang = (newLang: any) => {}

// 创建响应式的翻译函数
const translationVersion = ref(0)
const $t = (key: any, params?: any) => {
  // 依赖translationVersion来触发响应式更新
  translationVersion.value
  return t(key, params)
}

// 初始化翻译函数
const initTranslations = async () => {
  try {
    const fallback = await import('../../utils/i18n-fallback')
    t = fallback.t
    setLang = (newLang: any) => {
      fallback.setLang(newLang)
      translationVersion.value++
    }
    // 监听语言变化事件
    window.addEventListener('language-changed', () => {
      translationVersion.value++
    })
    // 强制更新一次以确保翻译生效
    translationVersion.value++
    console.log('Translation system initialized for member page')
  } catch (error) {
    console.warn('Failed to load i18n fallback:', error)
  }
}

const search = ref('')
const selectedId = ref('')
const users:any = ref([])
const pageNum = ref(1)
const pageSize = 18
const hasMore = ref(true)
const loading = ref(false)
const total = ref(0)
const currentUser = ref<string>('')
const totalPage = computed(() => Math.max(1, Math.ceil(total.value / pageSize)))

const router = useRouter()
function selectUser(user: any) {
  localStorage.setItem('user', JSON.stringify(user))
  // 触发自定义事件，通知其他页面更新缓存
  window.dispatchEvent(new CustomEvent('user-changed', { detail: user }))
    localStorage.removeItem('taskId')
  window.request?.('/system/patient/switchPatient/'+user.id, { method: 'GET',params:{
    patientId: user.id,
    
  } }).then(res => {
    console.log(res);
    
  })
  router.push('/')
}
function goReport(user: any) {
  // 触发自定义事件，通知其他页面更新缓存
  router.push({
    path: '/report',
    query: {
      userId: user.id
    }
  })
}
function goPlan(user: any) {
  // 触发自定义事件，通知其他页面更新缓存
  router.push({
    path: '/bag',
    query: {
      userId: user.id
    }
  })
}
function resetList() {
  users.value = []
  pageNum.value = 1
  hasMore.value = true
}

// 防抖搜索函数
let searchTimer: NodeJS.Timeout | null = null
let requestId = 0

function getUserList(loadMore = false) {
  // 生成新的请求ID
  const currentRequestId = ++requestId
  
  const loadingEl = ElLoading.service({
    lock: false,
    text: '加载中',
    background: 'rgba(0, 0, 0, 0)',
  })
  loading.value = true
  
  return window.request?.('/system/patient/list', {
    method: 'GET',
    params: {
      keyWord: search.value,
      pageNum: pageNum.value,
      pageSize
    }
  }).then(res => {
    // 只处理最新的请求结果
    if (currentRequestId === requestId) {
      loadingEl.close()
      if (res.rows.length==0) { 
        window.messageRef?.show($t('views.member.noUsersFound'), 'error')
      }
      
      const list = res?.rows || []
      total.value = res?.total || 0
      users.value = list
      hasMore.value = pageNum.value < totalPage.value
      loading.value = false
      
      // 返回接口数据
      return res?.rows || []
    } else {
      // 如果不是最新请求，只关闭loading
      loadingEl.close()
      return []
    }
  }).catch((error) => {
    // 只处理最新的请求错误
    if (currentRequestId === requestId) {
      loadingEl.close()
      loading.value = false
      console.error('Request failed:', error)
    } else {
      loadingEl.close()
    }
    return []
  })
}

function onScroll(e: Event) {
  const el = e.target as HTMLElement
  if (el.scrollHeight - el.scrollTop - el.clientHeight < 50) {
    // if (!loading.value && hasMore.value) {
    //   getUserList(true)
    // }
  }
}

function doSearch() {
  nextTick(() => {
    resetList()
    getUserList()
  })
}

// 防抖搜索函数
function doSearchDebounced() {
  if (searchTimer) {
    clearTimeout(searchTimer)
  }
  searchTimer = setTimeout(() => {
    doSearch()
  }, 300)
}

const addType = ref(0)
function editUser(user: any) {
  addType.value = 1
  form.value = JSON.parse(JSON.stringify(user))
  dialogRef.value.open()
}
const switchDialogRef = ref()
const switchUserName = ref('')
let switchUserObj: any = null
function switchUser(user: any) {
  switchUserName.value = user.name
  switchUserObj = user
  switchDialogRef.value.open()
}
const deleteDialogRef = ref()
const deleteUserName = ref('')
let deleteUserObj: any = null
function deleteUser(user: any) {
  deleteUserName.value = user.name
  deleteUserObj = user
  deleteDialogRef.value.open()
}
function addUser() {
  form.value={
    name: '',
    birthday: '',
    sex: 1,
    id: '',
    remark: ''
  }
  addType.value = 0
  dialogRef.value.open()
}
const form:any = ref({
  name: '',
  birthday: '',
  sex: 1,
  id: '',
  remark: ''
})
const dialogRef = ref()
function onFormConfirm() {
  // 校验姓名不能为空
  if (!form.value.name || !form.value.name.trim()) {
    window.messageRef?.show($t('views.member.pleaseEnterName'), 'error')
    return
  }
  
  if (addType.value === 0) {
    // 添加用户
    window.request?.('/system/patient', {
      method: 'POST',
      body: form.value
    }).then(res => {
      console.log(res)
      form.value={}
      window.messageRef?.show($t('views.member.addSuccess'))
      getUserList()
    })
  } else {  
    // 编辑用户
    window.request?.('/system/patient', {
      method: 'PUT',
      body: form.value
    }).then(res => {
      form.value={}

      console.log(res)
      window.messageRef?.show($t('views.member.editSuccess'))
      getUserList()
    })
  }
  // 校验和保存逻辑
  dialogRef.value.close()
}
function onSwitchConfirm() {
  // 这里写切换用户的实际逻辑，比如selectedId.value = switchUserObj.id
  selectedId.value = switchUserObj.id
  switchDialogRef.value.close()
}
function onDeleteConfirm() {
  // 实际删除逻辑
  if (!deleteUserObj?.id) return
  window.request?.(`/system/patient/${deleteUserObj.id}`, {
    method: 'DELETE',
  })
    .then(() => {
      getUserList()
      deleteDialogRef.value.close()
      // 可选：刷新用户列表
      // getUserList()
    })
}
function goPrevPage() {
  if (pageNum.value > 1) {
    pageNum.value--
  }
}
function goNextPage() {
  if (pageNum.value < totalPage.value) {
    pageNum.value++
  }
}
watch(pageNum, () => {
  getUserList()
})
onMounted(async () => {
  await initTranslations()

  let users: any = await getUserList()
  if (!localStorage.getItem('user')) {
    let user:any=users[0]
  localStorage.setItem('user', JSON.stringify(user))
  // 触发自定义事件，通知其他页面更新缓存
  window.dispatchEvent(new CustomEvent('user-changed', { detail: user }))
  localStorage.removeItem('taskId')

  window.request?.('/system/patient/switchPatient/'+user.id, { method: 'GET',params:{
    patientId: user.id,
    
  } }).then(res => {
    console.log(res);
    
  })
   }
 
  enableMemberListTouch()
  const userStr = localStorage.getItem('user')
  if (userStr) {
    try {
      const userObj = JSON.parse(userStr)
      currentUser.value = userObj.id || ''
    } catch {
      currentUser.value = ''
    }
  } else {
    currentUser.value = ''
  }
})
onUnmounted(() => {
  //选择用户
  if (!localStorage.getItem('user')) {
     window.dispatchEvent(new CustomEvent('user-changed', { detail: users.value[0] }))
     localStorage.removeItem('taskId')

  window.request?.('/system/patient/switchPatient/'+users.value[0].id, { method: 'GET',params:{
    patientId: users.value[0].id,
    
  } }).then(res => {
    console.log(res);
    
  })
  }
  disableMemberListTouch()
  // 清理搜索防抖定时器
  if (searchTimer) {
    clearTimeout(searchTimer)
    searchTimer = null
  }
  // 重置请求ID，确保旧请求结果不会被处理
  requestId = 0
})

function enableMemberListTouch() {
  const el = document.querySelector('.member-list') as HTMLElement
  if (!el) return
  let isTouching = false
  let startY = 0
  let scrollTop = 0
  // 触摸
  el.addEventListener('touchstart', function (e) {
    const te = e as TouchEvent
    if (te.touches.length !== 1) return
    isTouching = true
    startY = te.touches[0].pageY - el.offsetTop
    scrollTop = el.scrollTop
  }, { passive: true })
  el.addEventListener('touchmove', function (e) {
    if (!isTouching) return
    const te = e as TouchEvent
    if (te.touches.length !== 1) return
    const y = te.touches[0].pageY - el.offsetTop
    const walkY = y - startY
    el.scrollTop = scrollTop - walkY
    te.preventDefault()
  }, { passive: false })
  el.addEventListener('touchend', function () {
    isTouching = false
  })
  // 鼠标拖动
  let isDown = false
  let mouseStartY = 0
  let mouseScrollTop = 0
  el.addEventListener('mousedown', (e: MouseEvent) => {
    isDown = true
    mouseStartY = e.pageY - el.offsetTop
    mouseScrollTop = el.scrollTop
    el.classList.add('dragging')
  })
  el.addEventListener('mouseleave', () => {
    isDown = false
    el.classList.remove('dragging')
  })
  el.addEventListener('mouseup', () => {
    isDown = false
    el.classList.remove('dragging')
  })
  el.addEventListener('mousemove', (e: MouseEvent) => {
    if (!isDown) return
    e.preventDefault()
    const y = e.pageY - el.offsetTop
    const walkY = y - mouseStartY
    el.scrollTop = mouseScrollTop - walkY
  })
}
function disableMemberListTouch() {
  // 如需移除事件可在此实现
}

function onAvatarChange(e: Event) {
  const file = (e.target as HTMLInputElement).files?.[0]
  if (!file) return
  const formData = new FormData()
  console.log(file)
  formData.append('file', file)
  console.log(formData.get('file'))

  window.request?.('/common/upload', {
    method: 'POST',
    body: formData,
   
    showError: true
  }).then(res => {
    if (res && res.url) {
      form.value.headImage = res.url
    }
  })
}

function getPageNumbers() {
  const pageNumbers = []
  let start = Math.max(pageNum.value - 2, 1)
  let end = Math.min(pageNum.value + 2, totalPage.value)

  if (start > 1) {
    pageNumbers.push(1)
    if (start > 2) {
      pageNumbers.push('...')
    }
  }
  for (let i = start; i <= end; i++) {
    pageNumbers.push(i)
  }
  if (end < totalPage.value) {
    if (end < totalPage.value - 1) {
      pageNumbers.push('...')
    }
    pageNumbers.push(totalPage.value)
  }
  return pageNumbers
}

function goToPage(page: number | string) {
  if (typeof page === 'number') {
    pageNum.value = page
  }
}
</script>

<style scoped>
.icon-nv{
  color: #e91e63;
}
.icon-nan{
  color: #2196f3;
}
.member-bg {
  width: 100vw;
  height: 100vh;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}
.member-card {
  width: 90vw;
  max-width:90vw;
  height: 80vh;
  background: #fff;
  margin-top: -50px;
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(30,94,146,0.10), 0 2px 8px rgba(0,0,0,0.10);
  padding: 32px 32px 20px 32px;
  position: relative;
}
.member-search-row {
  display: flex;
  align-items: center;
  margin-bottom: 18px;
  border-radius: 20px;


}
.member-search {
  background: #dddddd;
  width: 80vw;
  height: 45px;
  border-radius: 20px;
  font-size: 18px;
	border: none;
  padding: 0 16px;
  outline: none;
}
.member-search-btn {
  width: 45px;
  height:  45px;
  margin-left: 10px;
  border: none;
  background: var(--theme-primary);
  color: #fff;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.member-list {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  margin-top: 18px;
  height: 66vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.2) transparent;
  -webkit-overflow-scrolling: touch;
}
.member-list::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
.member-list::-webkit-scrollbar-track {
  background: transparent;
}
.member-list::-webkit-scrollbar-thumb {
  background-color: rgba(0,0,0,0.2);
  border-radius: 2px;
}
.member-item {
  width: 13vw;
  height: 250px;
  border-radius: 8px;
  box-sizing: border-box;
  padding: 16px 12px 18px 12px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: url('../../assets/image/cardbg.png') no-repeat center center;
  background-size: 100% 100%;
}
.member-avatar-box {
  position: relative;
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
}
.member-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #f5f5f5;
  border: 1.5px solid #e0e0e0;
}
.member-edit-btn {
  position: absolute;
  top: 0;
  right: 0;
  background: #fff;
  border: 1px solid #bbb;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(30,94,146,0.10);
}
.member-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 4px;
}
.sex-icon {
  margin-left: 2px;
}
.member-info-row {
  color: #888;
  font-size: 15px;
  /* margin-bottom: 12px; */
}
.member-id {
  margin-left: 8px;
}
.member-btn-row {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}
.member-btn2 {
  background: var(--theme-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 18px;
  width: 87%;
  margin-top: 10px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s;
}
.member-btn {
  border: 1px solid #b3b4b6 !important;
  color: #333;
  border: none;
  border-radius: 8px;
  /* padding: 6px 18px; */
  width: 82px;
  font-size: 15px;
  cursor: pointer;
  background-color: #fff;
}

.member-add-btn {
  position: absolute;
  right: 32px;
  bottom: 24px;
  background: var(--theme-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 32px;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(30,94,146,0.10);
}
.member-add-btn:active {
  background: var(--theme-primary-hover);
}
.user-dialog-flex {
  display: flex;
  align-items: flex-start;
  gap: 40px;
  min-width: 600px;
  padding: 20px 10px 10px 10px;
}
.user-dialog-form {
  flex: 1;
  min-width: 320px;
}
.form-row {
  display: flex;
  align-items: center;
  margin-bottom: 18px;
  gap: 18px;
}
.form-label {
  min-width: 90px;
  color: #333;
  font-size: 17px;
}
.form-label.required {
  color: #158ac0;
  font-weight: bold;
}
.form-input {
  flex: 1;
  height: 36px;
  border: none;
  border-bottom: 1.5px solid #e0e6ed;
  border-radius: 0;
  padding: 0 10px;
  font-size: 16px;
  background: transparent;
  outline: none;
}
.form-input.underline:focus {
  border-bottom: 1.5px solid var(--theme-primary);
}
.sex-btn-group {
  display: flex;
  gap: 18px;
}
.sex-btn {
  width: 78px;
  height: 32px;
  border-radius: 16px;
  border: 1.5px solid #e0e6ed;
  background: #fff;
  color: #888;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s;
}
.sex-btn.active {
  color: #fff;
  border-color: var(--theme-primary);
  background: var(--theme-primary);
}
.user-dialog-avatar {
  width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 10px;
}
.avatar-img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: #e0e6ed;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  cursor: pointer;
  position: relative;
}
.avatar-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-upload-desc {
  color: #888;
  font-size: 15px;
  margin-bottom: 6px;
  text-align: center;
}
.dialog-btn {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 32px;
}
.dialog-confirm {
  min-width: 90px;
  background: var(--theme-secondary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 18px;
  padding: 8px 0;
  cursor: pointer;
  transition: background 0.2s;
}
.dialog-confirm:hover {
  background: #1e5e92;
}
.dialog-cancel {
  min-width: 90px;
  background: #f3f3f3;
  color: #888;
  border: none;
  border-radius: 8px;
  font-size: 18px;
  padding: 8px 0;
  cursor: pointer;
  transition: background 0.2s;
}
.dialog-cancel:hover {
  background: #e0e0e0;
}
.switch-dialog-content {
  min-width: 380px;
  padding: 30px 30px 10px 30px;
  text-align: center;
}
.switch-dialog-title {
  font-size: 22px;
  color: #222;
  margin-bottom: 10px;
  font-weight: 500;
}
.member-table tr.selected td {
  background: var(--theme-secondary) !important;
  color: #fff !important;
}
.member-item.selected {
  border: 2px solid var(--theme-primary);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.9);
}
.page {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 20px;
}
.page-btn {
  background: var(--theme-primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  margin: 0 10px;
  transition: background 0.2s;
}
.page-btn:hover {
  background: var(--theme-primary-hover);
}
.page-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}
.page-number {
  background: #fff;
  color: #333;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  margin: 0 5px;
  transition: background 0.2s;
}
.page-number:hover {
  background: var(--theme-primary);
  color: #fff;
}
.page-number.active {
  background: var(--theme-primary);
  color: #fff;
}
.page-ellipsis {
  color: #888;
  font-size: 18px;
  margin: 0 10px;
}
.form-date-picker {
  flex: 1;
  height: 36px;
}

.form-date-picker .el-input__wrapper {
  border: none;
  border-bottom: 1.5px solid #e0e6ed;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0 10px;
}

.form-date-picker .el-input__wrapper:hover,
.form-date-picker .el-input__wrapper.is-focus {
  border-bottom: 1.5px solid var(--theme-primary);
  box-shadow: none;
}
</style>